#pragma once
#include <qbmessage/include/message_bond.h>
#include <qbprotocol/include/SSQBModel.h>
#include <qbtools/message/MessagePoster.h>

#include <QList>
#include <QObject>
#include <QString>

class BondDataCenter : public QObject, public MessageReceiver {
  Q_OBJECT
 public:
  static BondDataCenter& instance();
  void requestQBACDCPriceNonSpecial();
  void requestQBACDCPriceSpecial();
  void requestBestPrice();
  void requestBrokerPriceReg();
  void requestQBMarketStreamDeal();
  void requestAllCSIV2();
  void requestBondLiquidity();
  void requestIssuerLiquidity();
  void requestHighYieldBond();
  void requestThirdPartyGuarantee();
  void requestSectorBond();
  void requestMarketMakeTarget();
  void requestQBCompanySort(int nEnableBroker, std::vector<int> stlSortShow);
  void requestMixedBestQuote(const char* contributorId);
  void requestABBondPrice();
  void subMixedBPPush(const char* contributorId);
  void unSubMixedBPPush(const char* contributorId);

 protected:
  void onDataArrived(const qb::SSAckMsg& msg) override;

 signals:
  void dealMarketPush(int funcId, QString, QList<xQBMarketStreamUnit_c>);
  void dealMarketPushAll(int funcId, QList<xQBMarketStreamUnit_c>);
  void bestPriceArrived(std::string, QList<xQBBestPriceUnit_c>);
  void bestPriceArrivedAll(QList<xQBBestPriceUnit_c>);
  void bestPriceReqArrivedAll();
  void mixedBestPriceArrived();
  void mixedBestPricePush(QList<xQBMixedBestQuoteUnit_c>);
  void companySorted();

 private:
  BondDataCenter();

  void saveMarketStreamDeal(const qb::SSAckMsg& msg);
  void notifyMarketStreamDeal(const qb::SSAckMsg& msg);
  void doMixedBestQuote(int funId, const char* contributorId);
};
